COVID-19 Vaccinations in the United States: A Study
Project Description
Introduction
Results
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For example, you can include Bold and Italic and Code text. For more details on using R Markdown see http://rmarkdown.rstudio.com.
You should test out updating your GitHub Pages website:
- clone your group’s blog project repo in RStudio
- update “Your Project Title Here” to a new title in the YAML header
- knit
index.Rmd - commit and push BOTH the
index.Rmdand theindex.htmlfiles - go to https://stat231-s21.github.io/Blog-library-cleanverse/ to see the published test document (this is publicly available!)
Including code and plots
You can embed code as normal, for example:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
Let’s clean up the format of that output:
In a study from the 1920s, fifty cars were used to see how the speed of the car and the distance taken to stop were related. Speeds ranged between 4 and 25 mph. Distances taken to stop ranged between 2 and 120 feet, with the middle 50% falling between 26 and 56 feet.
You can also embed plots as normal, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Including links and images
You can include Links and images
You can embed a gif.
ma example
usa vaccine number
Comparison: CA and TN
# read in and plot ca vax over time
library(tidyverse)
library(dplyr)
library(readxl)
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:viridis':
##
## viridis_pal
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
library(viridis)
ca_time <- read_csv("ca_time.csv") %>%
filter(race != "Unknown", race != "Other/Multiracial")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## race = col_character(),
## date = col_date(format = ""),
## count = col_double(),
## frac = col_double()
## )
ca_tg <- ggplot(ca_time, aes(x = date, y = frac, colour = race)) +
geom_line() +
labs(colour = "Race", title = "Proportion of Racial Groups Vaccinated Over Time",
subtitle = "California, 2021") +
xlab("Date") + ylab("Proportion of Racial Group")
ca_tg
# read in and plot tn vax over time
tn_time <- read_csv("tn_time.csv") %>%
filter(race != "UNKNOWN", race != "OTHER/MULTIRACIAL")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## date = col_date(format = ""),
## race = col_character(),
## count = col_double(),
## frac = col_double()
## )
tn_tg <- ggplot(tn_time, aes(x = date, y = frac, colour = race)) +
geom_line() +
labs(colour = "Race", title = "Proportion of Racial Groups Vaccinated Over Time",
subtitle = "Tennessee, 2021") +
xlab("Date") + ylab("Proportion of Racial Group")
tn_tg
# read in and plot ca county vaccinations
ca_county <- read_csv("ca_county.csv") %>%
mutate(subregion = tolower(county)) %>%
select(-county)
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## administered_date = col_date(format = ""),
## county = col_character(),
## total_vax = col_double()
## )
ca_counties <- map_data(map = "county", region = "california")
ca_map <- ca_counties %>%
left_join(ca_county, by = "subregion")
ggplot(ca_map, aes(x = long, y = lat, group = group, fill = total_vax)) +
geom_polygon(colour = "white") +
theme_void() +
coord_fixed(ratio = 1.3) +
facet_wrap(~administered_date) +
labs(fill = "Total Vaccinations") +
scale_fill_viridis(direction = -1) +
ggtitle("Vaccinations in California, Spring 2021")
# read in and plot tn county vaccinations
options(scipen = 999)
tn_county <- read_csv("tn_county.csv") %>%
mutate(subregion = tolower(COUNTY)) %>%
select(-COUNTY)
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## date = col_date(format = ""),
## COUNTY = col_character(),
## total_vax = col_double()
## )
tn_counties <- map_data(map = "county", region = "tennessee")
tn_map <- tn_counties %>%
left_join(tn_county, by = "subregion") %>%
na.omit()
ggplot(tn_map, aes(x = long, y = lat, group = group, fill = total_vax)) +
geom_polygon(colour = "white") +
theme_void() +
coord_fixed(ratio = 1.3) +
facet_wrap(~date) +
labs(fill = "Total Vaccinations") +
scale_fill_viridis(direction = -1) +
ggtitle("Vaccinations in Tennessee, Spring 2021")
Bulleted list
You can make a bulleted list like this:
- item 1
- item 2
- item 3
Numbered list
You can make a numbered list like this
- First thing I want to say
- Second thing I want to say
- Third thing I want to say
Politics and Vaccinations
R Markdown
#read in
ratios.1 <- read_csv("finalratios.csv")
## Warning: Missing column names filled in: 'X1' [1]
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## X1 = col_double(),
## state = col_character(),
## dem_votes = col_double(),
## rep_votes = col_double(),
## delivered = col_double(),
## delivered_100 = col_double(),
## admin = col_double(),
## admin_100 = col_double(),
## percent_one_18 = col_double(),
## percent_full_18 = col_double()
## )
#quick updates to dataset
ratios.2 <- ratios.1 %>%
select(-c(X1)) %>%
mutate(politics = case_when(dem_votes > rep_votes ~ "1", dem_votes < rep_votes ~ "0")) %>%
mutate(ratio_overall = admin/delivered) %>%
mutate(ratio_100 = admin_100/delivered_100)
#data for maps
usa_states <- map_data(map = "state", region = ".")
ratio_map <- ratios.2 %>%
right_join(usa_states, by = c("state" = "region"))
map_dem <- ratio_map %>%
filter(politics != 0)
map_rep <- ratio_map %>%
filter(politics != 1)
Including Plots
You can also embed plots, for example:
## `geom_smooth()` using formula 'y ~ x'
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.